package View.CoolSwing;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JMenuItem;

public class MyMenuItem extends JMenuItem{
    private static final Color COLOR1 = new Color(153, 222, 253); //color for border
    private static final Color COLOR2 = new Color(213, 239, 252); //color for up
    private static final Color COLOR3 = new Color(241, 248, 253); //color for down
	
	public MyMenuItem() {
		super();
	}

	public MyMenuItem(Action arg0) {
		super(arg0);
	}

	public MyMenuItem(Icon arg0) {
		super(arg0);
	}

	public MyMenuItem(String arg0, Icon arg1) {
		super(arg0, arg1);
	}

	public MyMenuItem(String arg0, int arg1) {
		super(arg0, arg1);
	}

	public MyMenuItem(String arg0) {
		super(arg0);
	}

	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		if  (super.isSelected()) {
		    int W = getWidth();
		    int H = getHeight();
	        
		    GradientPaint GP = new GradientPaint(0, 0, COLOR3, 0, getHeight(), COLOR2, true);
		    Graphics2D g2d 	= (Graphics2D) g.create();

		    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		    g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
		    g2d.setPaint(GP);
		    
		    g2d.fillRect(0, 0, W, H);
		   	g2d.dispose();
		}
	}
	
	@Override
	protected void paintBorder(Graphics g) {
		
	}
}
